package com.example.demo.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Message;
import com.example.demo.vo.messageDetailVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {


    @Select("select * from message where user_id=#{userId} and session_id=#{sessionId} and tag=#{tag} ORDER BY created_at ")
    @Results({
            @Result(property = "userId", column = "user_id"),
            @Result(property = "sessionId", column = "session_id"),
            @Result(property = "content", column = "content"),
            @Result(property = "type", column = "type"),
            @Result(property = "createdAt", column = "created_at")
    })
    List<messageDetailVO> getMessage(@Param("userId") Long userId,
                                     @Param("sessionId") Object sessionId,
                                     @Param("tag")Integer tag);

    @Select("select * from message where user_id=#{userId} and tag=#{tag} ORDER BY created_at ")
    @Results({
            @Result(property = "userId", column = "user_id"),
            @Result(property = "sessionId", column = "session_id"),
            @Result(property = "content", column = "content"),
            @Result(property = "type", column = "type"),
            @Result(property = "createdAt", column = "created_at")
    })
    List<messageDetailVO> getRagMessage(@Param("userId") Long userId,
                                     @Param("tag")Integer tag);
}
